package com.bdqn.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


public class ConfigManager {
    private static Properties properties;
    private static ConfigManager configManner;

    /**
     * 定义私有构造函数，解析配置文件
     */
    private ConfigManager(){
        String configFile= "database.properties";
        properties=new Properties();
        try (InputStream inputStream= ConfigManager.class.getClassLoader().getResourceAsStream(configFile)){
            properties.load(inputStream);
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    /**
     * 获取单例对象
     * @return
     */
    public static synchronized ConfigManager getInstance(){
        if (configManner == null) {
            configManner=new ConfigManager();
        }
        return configManner;
    }
    public String getValue(String key){
        return properties.getProperty(key);
    }
}
